<?php
include_once "config/config.php";

include_once "lib/employee_class.php";

include_once "lib/pdodbmanager.php";
include_once "lib/senitize.php";

$pdo_obj=new PDODBMNanager(HOST,DB,USERNAME,PASS);

$sen_obj=new SanitizeInput();

$general_obj=new General();

include_once "lib/functions.php";
// Include the main TCPDF library (search for installation path).
require_once('PDF/_tcpdf_5.0.002/tcpdf.php');

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, 'LETTER', true, 'UTF-8', false);
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);

$pdf->SetMargins(20, 5);  
 /*
 
 $pdf->SetLeftMargin(14);
$pdf->SetTopMargin(6);
$pdf->SetFooterMargin(0);
*/
$pdf->SetFont('', '', 10);

// create some HTML content
function convertDateToTime($date)
{
	if(trim($date)!="")
	{
		$datearr=explode("/",$date);
		$nowtimedate=mktime(0,0,1,$datearr[1],$datearr[0],$datearr[2]);
		return $nowtimedate;
	}
	else
	{
		return "";
	}
}

$fullname=$_POST['User']['first_name']." ".$_POST['User']['last_name'];
$_POST['User']['doj']=convertDateToTime($_POST['User']['doj']);


$designation_name=$general_obj->get_field_value($pdo_obj,"designations","id=".$_POST['User']['emp_designation'],"designation");

$department=$general_obj->get_field_value($pdo_obj,"departments","id=".$_POST["User"]['department'],"dept_name");
$ctc_offered=$_POST['User']['ctc_offered'];
/*
if(stristr($department,"sales"))
{
	$ctc_offered+=SALESINSENTIVES;
}
else if(stristr($department,"tech"))
{
	$ctc_offered+=TECHINSENTIVES;
}
*/

//$ctcintext=getwordformatofsalary($ctc);
$ctcinwords=getwordformatofsalary($ctc_offered);
$ctcinwords=firstWordCapitalize($ctcinwords);
$ctcinwords=trim($ctcinwords);
$ctc_offered=number_format($ctc_offered);

$showdoj=date("d<\s\u\p>S</\s\u\p> F Y",$_POST['User']['doj']);	

$pdo_obj->insertData("offer_letters",$_POST['User']);	
$pdf->AddPage();

$html='
<div style="text-align:right;" >
	<img src="images/thephonesupport.jpg" width="200px">
</div>
<table style="text-align:left;text-align:justify">
	<tr>
		<td height="18px"></td>
	</tr>
	<tr>
		<td align="right" style="padding-top:10px">
			Date: '.date("d-M-Y").'
		</td>
	</tr>
	<tr>
		<td height="13px"></td>
	</tr>	
	<tr>
		<td>
			Dear <b>'.$fullname.'</b>,
		</td>
	</tr>
	<tr>
		<td height="13px"></td>
	</tr>
	<tr>
		<td>
			Congratulations ! Further to the interview and discussions you have had with us, and the subsequent selection process, we are delighted to offer you the role of <b>'.$designation_name.'</b>. Your date of joining would be <b>'.$showdoj.'</b> and you will be on a probation period of six months.
		</td>
	</tr>
	<tr>
		<td height="13px"></td>
	</tr>
	<tr>
		<td>
			Your Annual Gross Remuneration (Cost to the Company) is Rs. <b>'.$ctc_offered.' /- ('.$ctcinwords.' Only)</b>, which includes your performance linked incentive. On your joining, you are expected to enter into an agreement, which details the scope, terms and conditions of your employment, the necessary training and the contractual obligation to be with The Phone Support. On successful completion of the probation and review thereof, your employment with the company will stand confirmed and you will be entitled to other allowances and benefits whatsoever, subject to the terms and conditions as per Company policies.
		</td>
	</tr>
	<tr>
		<td height="13px"></td>
	</tr>	
	<tr>
		<td>
			The duration of the classroom training will be purely based on business requirements. Company will solely reserve the right to make any further changes to the date of joining.
		</td>
	</tr>
	<tr>
		<td height="13px"></td>
	</tr>	
	<tr>
		<td>
			You would be required to work in a 9 hour shift anytime in a 24*7 environment, with a one hour break a day and you are scheduled to have 2 weekly offs. You will be required to work in night shifts as well.
		</td>
	</tr>
	<tr>
		<td height="13px"></td>
	</tr>	
	<tr>
		<td>
			Your employment will be governed by the rules, regulations and policies of the Company.
		</td>
	</tr>
	<tr>
		<td height="13px"></td>
	</tr>	
	<tr>
		<td>
			The terms of this offer letter shall remain confidential and are not to be disclosed to any third party.
		</td>
	</tr>
	<tr>
		<td height="13px"></td>
	</tr>	
	<tr>
		<td>
			This offer stands cancelled in case of any deviations in information or if you fail to report on or before the pre-decided date.
		</td>
	</tr>
	<tr>
		<td height="13px"></td>
	</tr>	
	<tr>
		<td>
			You will need to submit all the following documents at the time of joining (Kindly bring original copies too) :
		</td>
	</tr>
	<tr>
		<td >
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a) Photocopies of your Educational qualification certificates (2 copies)
		</td>
	</tr>
	<tr>
		<td style="padding-left:50px">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b) PAN Card (4 copies) 
		</td>
	</tr>
	<tr>
		<td style="padding-left:50px">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c) Driving License (4 copies)
		</td>
	</tr>
	<tr>
		<td style="padding-left:50px">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d) Passport (4 copies)
		</td>
	</tr>
	<tr>
		<td style="padding-left:50px">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e) Photographs (Passport & Stamp Size photographs should be identical) 
		</td>
	</tr>
	<tr>
		<td style="padding-left:50px">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i) Passport Size Photographs (7) 
		</td>
	</tr>
	<tr>
		<td style="padding-left:50px">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ii) Stamp Size Photographs (4)
		</td>
	</tr>
	<tr>
		<td style="padding-left:50px">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; f) Work Experience Proof (2 copies)
		</td>
	</tr>
	<tr>
		<td style="padding-left:50px">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i) Experience Letter
		</td>
	</tr>
	<tr>
		<td style="padding-left:50px">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ii) Relieving Letter
		</td>
	</tr>
	<tr>
		<td style="padding-left:50px">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iii) Salary Slips / Bank Statements (last 6 months)
		</td>
	</tr>
	<tr>
		<td height="13px"></td>
	</tr>	
	<tr>
		<td>
			Welcome to The Phone Support. We wish you a long, rewarding and fulfilling career and look forward to your joining us.
		</td>
	</tr>
	<tr>
		<td>
		</td>
	</tr>	
	<tr>
		<td>
			Warm Regards,
		</td>
	</tr>	
	<tr>
		<td height="10px"></td>
	</tr>
	<tr>
		<td>
			<b>Human Resources</b>
		</td>
	</tr>	
	<tr>
		<td>
			<b>The Phone Support</b>
		</td>
	</tr>
	
		
</table>

';

$pdf->SetAutoPageBreak(TRUE, 0);

// output the HTML content
$pdf->writeHTML($html, true, 0, true, 0);
$next_html="<br><hr><p style='color:#d3d3d3'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The Phone Support Pvt. Ltd., G-2, Evolve Tower B-1, IT/ITeS SEZ, Mahindra World City, Village Kalwara, <br> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JAIPUR -302037 (Rajasthan) INDIA Mobile: 0141-2243030 / 2243031 <br> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Web: http://www.thephonesupport.com E-mail: hr@thephonesupport.com </p>";
$pdf->writeHTML($next_html, true, 0, true, 0);

// reset pointer to the last page
//$pdf->lastPage();

// ---------------------------------------------------------

//Close and output PDF document
//$pdf->Output($fullname.'_OfferLetter.pdf', 'D');
$pdf->Output($fullname.'_OfferLetter.pdf', 'D');

//============================================================+
// END OF FILE
//============================================================+
